<template>
  <view class="nav-bar">
    <nut-navbar
      class="safe-area-inset-top"
      :title="title"
      :style="{ background: backgroundColor }"
    >
      <template #left>
        <i
          style="font-size: 20px;color:#222"
          class="iconfont icon-fanhui"
          @click="goBack()"
        ></i>
      </template>
      <template #right> </template>
    </nut-navbar>
  </view>
</template>

<script setup lang="ts">
import { onMounted } from "vue";
import { navigateTo , navigateBack} from "@tarojs/taro";

const props = defineProps(["title",'backgroundColor']);
// 找到nut-navbar的dom，然后给加上backgroundColor
onMounted(() => {
  const navbar = document.querySelector(".nut-navbar");
  navbar?.setAttribute("style", `background:${props.backgroundColor}`);
});
const goBack = () => {
  navigateBack({
    delta: 1
  })
}
</script>

<style lang="less">
@import "./index.less";
</style>
